/*******************************************
Module: zt_json.h
E-Mail: 24zhutian@gmail.com
Notices: Copyright (c) 2007-2011 ls
*******************************************/
#ifndef zt_json_h
#define zt_json_h
#ifdef __cplusplus
extern "C" {
#endif

/* cJSON Types: */
#define ZT_JSON_False		0
#define ZT_JSON_True		1
#define ZT_JSON_NULL		2
#define ZT_JSON_Number		3
#define ZT_JSON_String		4
#define ZT_JSON_Array		5
#define ZT_JSON_Object		6	
#define ZT_JSON_IsReference 256

typedef struct zt_json_s zt_json_t;
struct zt_json_s{
	zt_json_t *next,*prev;	/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
	zt_json_t *child;		/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
		
	int type;					/* The type of the item, as above. */
		
	u_char *valuestring;			/* The item's string, if type==cJSON_String */
	int valueint;				/* The item's number, if type==cJSON_Number */
	double valuedouble;			/* The item's number, if type==cJSON_Number */
		
	u_char *string;				/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
};

ZT_API void			zt_json_malloc_free(void *(*malloc_fn)(size_t),void (*free_fn)(void *));
ZT_API zt_json_t*	zt_json_load(const u_char *str);
ZT_API void			zt_json_free(zt_json_t *json);
	
#ifdef __cplusplus
}
#endif /* C++ */
#endif /* zt_json_h */